package com.twu.biblioteca.view;

import com.twu.biblioteca.models.Book;
import com.twu.biblioteca.models.Library;

/**
 * Created with IntelliJ IDEA.
 * User: ema93sh
 * Date: 8/9/13
 * Time: 5:48 PM
 */
public class BookView implements MenuItem {
    private Library library;

    public BookView(Library library) {
        this.library = library;
    }

    @Override
    public String displayTitle() {
        return "Display all books";
    }

    @Override
    public void doWork() {
       int count = 1;
       System.out.println("ID\t\tTitle\t\tTotal Copies\t\tCopies Available");
       for ( Book book : library.getAllBooks())
       {
           System.out.println(count + "\t\t" + book.getTitle() + "\t\t" + book.getNoOfCopies() +
                   "\t\t" + book.getNoOfCopiesAvailable());
           count++;
       }
       count--;
       System.out.println("Total No of books: " + count);
    }
}
